
package net.lab0.fractal.gui;


import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import net.lab0.fractal.classes.RenderingCoordinates;
import net.lab0.fractal.classes.ViewCoordinates;
import net.lab0.fractal.fractals.mandelbrot.BasicMandelbrotFractal;
import javax.swing.JMenuItem;


@SuppressWarnings("serial")
public class MainWindow2
extends JFrame
{
    private final JMenuBar    menuBar        = new JMenuBar();
    private final JMenu       mnFile         = new JMenu("File");
    private final JTabbedPane tabbedPane     = new JTabbedPane(JTabbedPane.TOP);
    private final JMenu       mnNew          = new JMenu("New");
    private final JMenuItem   mntmFractalTab = new JMenuItem("Fractal Tab");
    
    public MainWindow2()
    {
        initComponents();
    }
    
    private void initComponents()
    {
        
        setJMenuBar(menuBar);
        
        menuBar.add(mnFile);
        
        mnFile.add(mnNew);
        
        mntmFractalTab.addActionListener(new ActionListener()
        {
            
            @Override
            public void actionPerformed(ActionEvent e)
            {
                FractalPanel fractalPanel = new FractalPanel(new BasicMandelbrotFractal(new RenderingCoordinates(new ViewCoordinates(0.0, 0.0, 2.0, 2.0), 512, 512), 1024, 0.1f,
                250L));
                
                tabbedPane.addTab("Fractal", null, fractalPanel, null);
            }
        });
        mnNew.add(mntmFractalTab);
        
        getContentPane().add(tabbedPane, BorderLayout.CENTER);
    }
    
    public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                try
                {
                    // Set System L&F
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                }
                catch (UnsupportedLookAndFeelException e)
                {
                    // handle exception
                }
                catch (ClassNotFoundException e)
                {
                    // handle exception
                }
                catch (InstantiationException e)
                {
                    // handle exception
                }
                catch (IllegalAccessException e)
                {
                    // handle exception
                }
                
                JFrame f = new MainWindow2();
                f.setSize(new Dimension(600, 400));
                f.setVisible(true);
            }
        });
    }
}
